package org.dmcs.spring.webflow.service;

import java.util.logging.Logger;

import org.dmcs.spring.webflow.model.user.User;
import org.dmcs.spring.webflow.service.api.IPasswordReminderService;
import org.dmcs.spring.webflow.service.api.IUserProviderService;

public class PasswordReminderServiceMock implements IPasswordReminderService {

	public static Logger LOGGER = Logger.getLogger(PasswordReminderServiceMock.class.getName());
	
	private IUserProviderService userProviderService;
	
	public boolean canRemindPassword( User credentials) {
		
		User userCredentials = userProviderService.getUserCredentials();
		
		if(credentials.getUsername().equalsIgnoreCase(userCredentials.getUsername()) &&
				credentials.getEmail().equalsIgnoreCase(userCredentials.getEmail())) {
			
			LOGGER.info("UserCredentials with credentials: " + credentials + " qualifies for password reminding.");
			
			return true;
		}
	
		LOGGER.info("UserCredentials with credentials: " + credentials + " does not qualify for password reminding.");
		
		return false;
	}

	public void remindPassword() {
		
		User userCredentials = userProviderService.getUserCredentials();
		
		LOGGER.info("UserCredentials password reminder: " + userCredentials.getPassword());
	}
	
	public void setUserProviderService(IUserProviderService userProviderService) {
		this.userProviderService = userProviderService;
	}
}